<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .box{
            position: relative;
            top: 200px;
            left: 100px;
            width: 200px;
            height: 200px;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
        const box=document.querySelector('.box');
        //鼠标移入变颜色，移开恢复
        box.addEventListener('mouseenter',function(){
            box.style.backgroundColor='deeppink';
        });
        box.addEventListener('mouseleave',function(){
            box.style.backgroundColor='pink';
            //box.style.backgroundColor='';
        })
    </script>
</body>
</html>